<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .update_center{
            padding: 30px 0px;
            width: 100%;
            height: 400px;
            background-color: #0F8FCB;
        }
        .update_user{
            float: none;
            margin: 0px auto;
            width: 450px;
            background-color: #F0F0F0;

            height: 320px;
        }
        .title{
            padding-top: 20px;
            width: 300px;
            height: 51px;
            margin: 10px auto;
            border-bottom: 1px solid #CCC;
            font-size: 18px;
            font-weight: bold;
        }
        .layui-form-item .layui-inline {
            margin-bottom: 5px;
            margin-left: 80px;
        }
        .layui-form-item {
            margin-bottom: 10px;
        }
        #updatePwdBtn{
            cursor: pointer;
            width: 254px;
            height: 35px;
            border-radius: 4px;
            color: #fff;
            font-size: 16px;
            margin-left: 100px;
        }
    </style>
</head>
<body>
<div class="updateped_top" style="width: 300px;height: 100px"></div>
<div class="update_center">
    <div class="update_user">

    <div class="title">
        <span>修改密码</span>
        <br>
    </div>

    <form class="layui-form" action="" style="margin-top: 30px;">
        <div class="layui-form-item ">

    <div class="layui-inline ">
        <label class="layui-form-label">用户名:</label>
        <div class="layui-input-inline">
            <input type="text" id="stationPhoneVal" autocomplete="off" class="layui-input" placeholder="请输入用户名">
        </div>
    </div>
        </div>

            <div class="layui-form-item ">

    <div class="layui-inline ">
        <label class="layui-form-label">旧密码:</label>
        <div class="layui-input-inline">
            <input type="password" id="stationJiuPwd" autocomplete="off" class="layui-input" placeholder="请输入旧密码">
        </div>
    </div>
            </div>

                <div class="layui-form-item ">

    <div class="layui-inline ">
        <label class="layui-form-label">新密码:</label>
        <div class="layui-input-inline">
            <input type="password" id="stationPasswordVal" autocomplete="off" class="layui-input" placeholder="请输入新密码">
        </div>
    </div>
                </div>
        <div class="layui-inline">
            <button type="button" class="layui-btn" id="updatePwdBtn">修改</button>
        </div>

    </form>
    </div>

</div>
</body>
<script>
    function GetRequest() {
        var url = decodeURI(location.search); //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    var json=GetRequest();
    layui.use(['form', 'layedit'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit;


    $.ajax({
        url:"/admin/station/stationName?stationid="+json.id,
        method:"get",
        success:function (data) {
            $("#stationPhoneVal").val(data.data.stationPhone);

        }
    })

        $("#updatePwdBtn").click(function () {
            var friend={
                "stationPhone":$("#stationPhoneVal").val(),
                "jiupwd":$("#stationJiuPwd").val(),
                "stationPassword":$("#stationPasswordVal").val()
            }
            $.ajax({
                    url:"/admin/station/updateStationPwd",
                    method:"put",
                contentType:"application/json;charset=utf-8",
                    data:JSON.stringify(friend),
                    success:function (res) {
                        console.log(res);
                        if (res.code==500){
                            layer.msg(res.data,{
                                icon:6,  //失败的表情
                                time:1000 //2秒关闭

                            });
                        }else if(res.code==200){
                            layer.msg("修改成功",{icom:5,time: 1000},function () {
                                location="/";
                                }
                            ) ;
                            return ;
                        }

                    }
                }


            )
        })


    })
</script>
</html>